﻿#region Namespace Imports

using System;
using System.Collections.Generic;
using GeoAPI.Coordinates;
using GeoAPI.Geometries;
using NPack.Interfaces;

#endregion

namespace GeoAPI.IO.WellKnownBinary
{
    public class WkbWriter<TCoordinate> : IWkbWriter<TCoordinate>
        where TCoordinate : ICoordinate<TCoordinate>, IEquatable<TCoordinate>,
                            IComparable<TCoordinate>, IConvertible,
                            IComputable<Double, TCoordinate>
    {
        public static Byte[] ToWkb(IGeometry<TCoordinate> geometry)
        {
            return GeometryToWkb.Write(geometry);
        }

        public static Byte[] ToWkb(IGeometry<TCoordinate> geometry, WkbByteOrder byteOrder)
        {
            return GeometryToWkb.Write(geometry, byteOrder);
        }

        private WkbByteOrder _byteOrder;

        public WkbWriter() : this(WkbByteOrder.LittleEndian) { }

        public WkbWriter(WkbByteOrder byteOrder)
        {
            _byteOrder = byteOrder;
        }

        #region IWkbEncoder Members

        public IEnumerable<Byte> LazyWrite(IGeometry<TCoordinate> geometry)
        {
            throw new NotImplementedException();
        }

        public Byte[] Write(IGeometry<TCoordinate> geometry)
        {
            return GeometryToWkb.Write(geometry);
        }

        public WkbByteOrder ByteOrder
        {
            get { return _byteOrder; }
            set { _byteOrder = value; }
        }
        #endregion

        #region IWkbWriter Members

        IEnumerable<Byte> IWkbWriter.LazyWrite(IGeometry geometry)
        {
            throw new NotImplementedException();
        }

        Byte[] IWkbWriter.Write(IGeometry geometry)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}